home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F28050_SpokenLanguageMessage.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.4 KB  |  94 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       XSLT
  4.   Sub-category:   xsl:message
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylesheet demonstrates the use of xsl:message to
  10.     display a message to the user based on a condition.  In this
  11.     stylesheet, an user-friendly error message is displayed when
  12.     a    language that can not be handled is found.
  13.  =============================================================== -->
  14. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  15. <xsl:output method="html"/>
  16. <xsl:include href="Style.xsl" />
  17.  
  18.  
  19. <!-- Template for root rule -->
  20. <xsl:template match="/">
  21.     <!-- Set Formatting Characteristics -->
  22.     <xsl:call-template name="Style1"/>
  23.     <xsl:apply-templates/>
  24. </xsl:template>
  25.  
  26.  
  27. <!-- Template for "employees" elements -->
  28. <xsl:template match="employees">
  29.     <h1>Employee listing that will display a message to the user.</h1>
  30.  
  31.     <!-- Table Header Creation -->
  32.     <table border="1">
  33.     <tr>
  34.     <th>Department</th>
  35.     <th>Name</th>
  36.     <th>Hourly Rate</th>
  37.     <th>Programming Language</th>
  38.     <th>Spoken Language</th>
  39.     </tr>
  40.  
  41.     
  42.     <xsl:for-each select="employee">
  43.         <tr>            
  44.             <td><xsl:value-of select="department" /></td>
  45.             <td><xsl:value-of select="employeename" /></td>
  46.             <td><xsl:value-of select="hourlyrate" /></td>
  47.             <td><xsl:value-of select="primarylanguage" /></td>
  48.             <td>
  49.             <xsl:choose>
  50.                 <xsl:when test="nativelanguage='EN'">
  51.                     <xsl:value-of select="'English'" />
  52.                 </xsl:when>
  53.                 <xsl:when test="nativelanguage='FR'">
  54.                     <xsl:value-of select="'French'" />
  55.                 </xsl:when>
  56.                 <xsl:when test="nativelanguage='SP'">
  57.                     <xsl:value-of select="'Spanish'" />
  58.                 </xsl:when>
  59.                 <xsl:when test="nativelanguage='TH'">
  60.                     <xsl:value-of select="'Thai'" />
  61.                 </xsl:when>
  62.                 <xsl:when test="nativelanguage='GR'">
  63.                     <xsl:value-of select="'German'" />
  64.                 </xsl:when>
  65.  
  66.                 <xsl:otherwise>
  67.                     <xsl:message terminate="no" >
  68.                     Error: Invalid language of: <xsl:value-of select="nativelanguage" />
  69.                     was found.  "Unknown" will be used.
  70.                     </xsl:message>
  71.  
  72.                     <xsl:value-of select="'Unknown'" />
  73.                 </xsl:otherwise>
  74.  
  75.             </xsl:choose>
  76.             </td>
  77.             
  78.  
  79.         </tr>
  80.     </xsl:for-each>
  81.  
  82.  
  83.  
  84.  
  85.     <!-- End of Table -->
  86.     </table>
  87.  
  88. </xsl:template>
  89.  
  90.  
  91.  
  92.  
  93.  
  94. </xsl:stylesheet>